<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%-- 
    JSP Name : endlist.jsp
    Description : 종료 이벤트 리스트
    author jkKim
    since 2012. 5. 10.
    version 1.0
    Modification Information
       since          author              description
    ===========    =============    ===========================
    2012. 5. 10.     jkKim     최초 생성
--%>
<%@ include file="/WEB-INF/jsp/com/include/declare.jspf" %>
<%@ include file="/WEB-INF/jsp/com/include/doctype.jspf" %>
<script>
function openLayer1(evntMnSn){
    $.ajax({
        type: "GET",
        dataType : "text",
        url: "<c:url value='/evnt/evntWnrLayer.do'/>",
        data: { 
            'evntMnSn' : evntMnSn
        },
        success: function(data){
            if(data){
                $("#layerpopup-winnerpopup").html('');
                $("#layerpopup-winnerpopup").append(data);
                $('body').dimmedFrame();
                $("#winnerpopup").css({top:$(window).scrollTop()+250}).show();
            }
        }
    });
    
}

function closeLayer1(){
    $('.dimmed-frame').remove();
    $("#winnerpopup").hide(); 
}

function checkWinner(evntMnSn){
    var hpNo1 = $("#hpNo1");
    var hpNo2 = $("#hpNo2");
    var hpNo3 = $("#hpNo3");
    var mbrNm = $("#mbrNm");
    
    if(hpNo2.val() == "" || hpNo2.val().length<3){
        alert("전화번호를 입력해 주세요.");
        hpNo2.focus();
        return;
    }
    if(hpNo3.val() == "" || hpNo3.val().length<4){
        alert("전화번호를 입력해 주세요.");
        hpNo3.focus();
        return;
    }
    
    if(mbrNm.val() == ""){
        alert("성명을 입력해 주세요.");
        mbrNm.focus();
        return;
    }
    var ptcChidHpNo = hpNo1.val()+hpNo2.val()+hpNo3.val();
    var ptcChidNm = mbrNm.val();
    
    
    $.ajax({
        type: "POST",
        dataType : "xml",
        url: "<c:url value='/evnt/selectEvntWnrDetail.do'/>",
        data: { 
            'evntMnSn' : evntMnSn,
            'ptcChidHpNo' : ptcChidHpNo,
            'ptcChidNm' : ptcChidNm
        },
        success: function(data){
            var result={};
            var items = $(data).find("item");
            items.each(function(index,element){
               var name = $(this).find("name").text();
               var value = $(this).find("value").text();
               result[name] = value;
            });
            if(result["result"] =="OK"){
                $.ajax({
                    type: "POST",
                    dataType : "text",
                    url: "<c:url value='/evnt/evntWnrMemoLayer.do'/>",
                    data: { 
                        'evntMnSn' : evntMnSn,
                        'winCd' : result["value"]
                    },
                    success: function(data){
                        if(data){
                            $("#layerpopup-winnerpopup").html('');
                            $("#layerpopup-winnerpopup").append(data);
                            $('body').dimmedFrame();
                            $("#winnerpopup").hide();
                            $("#layerpopup-winnerpopup2").html('');
                            $("#layerpopup-winnerpopup2").append(data);
                            var wHeight = $(window).height();
                            var divHeight = $("#winnerpopup02").height();
                            if(divHeight > wHeight){
                                $("#winnerpopup02").css({top:$(window).scrollTop()});    
                            }else{
                                $("#winnerpopup02").css({top:$(window).scrollTop()+((wHeight - divHeight) /2)});
                            }
                            
                            $("#winnerpopup02").show();
                        }
                    }
                });
            }else{
                $.ajax({ 
                    type: "POST",
                    dataType : "text",
                    url: "<c:url value='/evnt/evntFailLayer.do'/>",
                    data: { 
                        'evntMnSn' : evntMnSn 
                    },
                    success: function(data){
                        if(data){
                            $("#layerpopup-winnerpopup").html('');
                            $("#layerpopup-winnerpopup").append(data);
                            $('body').dimmedFrame();
                            $("#winnerpopup").hide();
                            $("#layerpopup-winnerpopup2").html('');
                            $("#layerpopup-winnerpopup2").append(data);
                            var wHeight = $(window).height();
                            var divHeight = $("#winnerpopup02").height();
                            if(divHeight > wHeight){
                                $("#winnerpopup02").css({top:$(window).scrollTop()});    
                            }else{
                                $("#winnerpopup02").css({top:$(window).scrollTop()+((wHeight - divHeight) /2)});
                            }
                            
                            $("#winnerpopup02").show();
                        }
                    }
                });
                
            }
        }
    });
    
}

function evntPrint(id) {
    $('#'+id).printArea({mode: 'popup', popupClose: false});

}

function eventSubList(pageIndex) {
    $("#pageIndex").val(pageIndex);

    var form = document.serchForm;
    form.action = "<c:url value='/evnt/selectEvntMnEndPaging.do'/>";
    form.submit();
}

</script>
</head>
<body>
<!-- 당첨자 발표 -->
<div id="winnerpopup" class="layerpopup winnerpopup"><div class="layerpopup-inner">
    <div class="layerpopup-head">
        <h1><img src="/kr/images/layerpopup/h1_winner.gif" alt="당첨자 발표" /></h1>
        <p class="desc"><img src="/kr/images/layerpopup/h1_winner_desc.gif" alt="이벤트에 참여해주신 모든 고객님들께 감사 드립니다." /></p>
    </div>
    <div class="layerpopup-contents" id="layerpopup-winnerpopup">
        
    </div>
    <!-- close -->
    <div class="close-area"><div class="close-area-inner">
        <img src="/kr/images/layerpopup/btn_close.gif" alt="닫기" class="close" />
    </div></div>
    <!-- //close -->
</div></div>
<!-- //당첨자 발표 -->

<!-- 당첨자 발표2 -->
<div id="winnerpopup02" class="layerpopup winnerpopup02"><div class="layerpopup-inner">
    <div class="layerpopup-head">
        <h1><img src="/kr/images/layerpopup/h1_winner.gif" alt="당첨자 발표" /></h1>
        <p class="desc"><img src="/kr/images/layerpopup/h1_winner_desc.gif" alt="이벤트에 참여해주신 모든 고객님들께 감사 드립니다." /></p>
    </div>
    <div class="layerpopup-contents" id="layerpopup-winnerpopup2">
        
    </div>
    <!-- close -->
    <div class="close-area"><div class="close-area-inner">
        <img src="/kr/images/layerpopup/btn_close.gif" alt="닫기" class="close" />
    </div></div>
    <!-- //close -->
</div></div>
<!-- //당첨자 발표2 -->
<%@ include file="/WEB-INF/jsp/com/include/layerpopup.jspf" %>
<div id="wrap" class="non-subnavigation">
    <%@ include file="/WEB-INF/jsp/com/include/navi_utill_sub.jspf" %>
    <%@ include file="/WEB-INF/jsp/com/include/navi_header.jspf" %>
    <hr />

    <%@ include file="/WEB-INF/jsp/com/include/sub_header_event02.jspf" %>
    <hr />
    <form method="get" action="" name="serchForm" id="serchForm" onsubmit="return false">
        <input type="hidden" name="pageIndex" id="pageIndex" value=""> 
    </form> 
    <div id="container">
        <div id="subtitle-area"><div class="subtitle-area-inner">
            <%@ include file="/WEB-INF/jsp/com/include/location.jspf" %>
        </div></div>
        <div id="article">
            <p class="default-desc"><img src="/kr/images/event/txt_event02_01.gif" alt="지난 이벤트 조회 및 당첨여부를 확인하실 수 있습니다." /></p>
            <div class="event-list event-list-type02">
                <c:forEach var="result" items="${resultList}" varStatus="status">
                <div class="section">
                    <a href="/kr/evnt/selectEvntMnDetailEnd.do?evntMnSn=${result.evntMnSn}">
                    <img src="<c:url value='${result.thumnImgPath}'/>" alt="${result.evntTitl}" class="thumb" />
                    </a>
                    <ul class="information">
                        <li>
                            <strong class="title"><img src="/kr/images/event/txt_event01_02.gif" alt="제목" /></strong>
                            <p class="subject"><a href="/kr/evnt/selectEvntMnDetailEnd.do?evntMnSn=${result.evntMnSn}">${result.evntTitl}</a></p>
                        </li>
                        <li>
                            <strong class="title"><img src="/kr/images/event/txt_event01_03.gif" alt="내용" /></strong>
                            <p>${result.evntSbc}</p>
                        </li>
                        <li>
                            <strong class="title"><img src="/kr/images/event/txt_event01_04.gif" alt="기간" /></strong>
                            <p>${fn:substring(result.strtDt, 0, 4)}-${fn:substring(result.strtDt, 4, 6)}-${fn:substring(result.strtDt, 6, 8)} ~ ${fn:substring(result.fnhDt, 0, 4)}-${fn:substring(result.fnhDt, 4, 6)}-${fn:substring(result.fnhDt, 6, 8)}</p>
                        </li>
                        <li>
                            <strong class="title"><img src="/kr/images/event/txt_event01_05.gif" alt="대상" /></strong>
                            <p><c:if test="${result.evntSubj == 'E1'}">
                                <able:hmcCodeTag type="codeNm" gCd="EVNTUBJ" comCd="E1"/>
                                </c:if>
                                <c:if test="${result.evntSubj == 'E2'}">
                                <able:hmcCodeTag type="codeNm" gCd="EVNTUBJ" comCd="E2"/>
                                </c:if></p>
                        </li>
                    </ul>
                    <c:if test="${result.evntType != 'E4'}">
                        <c:if test="${result.st == 'P'}">
                            <img src="/kr/images/common/button/btn_winner_ing.gif" alt="당첨자 선정중" class="winner-btn" />
                        </c:if>
                        <c:if test="${result.st == 'S'}">
                            <a href="javascript:openLayer1('${result.evntMnSn}');"><img src="/kr/images/common/button/btn_winner_view.gif" alt="당첨자 보기" class="winner-btn" /></a>
                        </c:if>
                    </c:if>
                </div>
                </c:forEach>
            </div>
            <c:if test="${paginationInfo.totalRecordCount >= 0 }">
                <div class="paging">
                    <able:pagination paginationInfo="${paginationInfo}" type="image" jsFunction="eventSubList" />
                </div>
            </c:if>
        </div>
    </div>
    <hr />
    <%@ include file="/WEB-INF/jsp/com/include/footer.jspf" %>